package com.icode.core.dto.order;

import com.icode.core.model.order.ReFund;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: xianfei
 * Date: 15-2-10
 * Time: 下午1:21
 * To change this template use File | Settings | File Templates.
 */
public class ReFundDTO {

    private String id;
    private String guid;
    private String refundDate;
    private String batchNo;
    private String tradeNo;
    private String price;
    private String reason;
    private String refundStatus;

    public ReFundDTO() {
    }

    public ReFundDTO(String id, String guid, String refundDate, String batchNo, String tradeNo, String price, String reason, String refundStatus) {
        this.id = id;
        this.guid = guid;
        this.refundDate = refundDate;
        this.batchNo = batchNo;
        this.tradeNo = tradeNo;
        this.price = price;
        this.reason = reason;
        this.refundStatus = refundStatus;
    }

    public static ReFundDTO toDTO(ReFund reFund) {
        String detailData = reFund.detailData();
        String[] result = detailData.split("\\^");
        return new ReFundDTO(reFund.id(), reFund.guid(), reFund.refundDate(), reFund.batchNo(), reFund.tradeNo(), reFund.price(), result[2], reFund.refundStatus());
    }

    public static List<ReFundDTO> toDTOs(List<ReFund> reFunds) {
        List<ReFundDTO> reFundDTOs = new ArrayList<>();
        for (ReFund r : reFunds) {
            ReFundDTO reFundDTO = ReFundDTO.toDTO(r);
            reFundDTOs.add(reFundDTO);
        }
        return reFundDTOs;
    }

    public void setRefundDate(String refundDate) {
        this.refundDate = refundDate;
    }

    public void setBatchNo(String batchNo) {
        this.batchNo = batchNo;
    }

    public void setTradeNo(String tradeNo) {
        this.tradeNo = tradeNo;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public String getRefundDate() {

        return refundDate;
    }

    public String getBatchNo() {
        return batchNo;
    }

    public String getTradeNo() {
        return tradeNo;
    }

    public String getPrice() {
        return price;
    }

    public String getReason() {
        return reason;
    }

    public String getId() {
        return id;
    }

    public String getGuid() {
        return guid;
    }

    public String getRefundStatus() {
        return refundStatus;
    }
}
